class <%= @migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
  def up
    execute <<~SQL
<%- function_definitions.each do |f| -%>
<%= inject_sql("#{f.name}.sql", indent: 6) %>
<%- end -%>
    SQL
  end

  def down
<%- unless update? -%>
    execute <<~SQL
  <%- function_definitions.each do |f| -%>
      DROP FUNCTION IF EXISTS <%= f.name %>(<%= f.signature %>) CASCADE;
  <%- end -%>
    SQL
<%- end -%>
  end
end
